#news_rss_url = "http://finance.yahoo.com/rss/headline?s=yhoo" 
import feedparser 
import time 
from thesocialstockmarket.recommendation.import_fluctuations import * 


def save_all(): 
    stock = create_stock_if_dont_exists('GOOG', 'Google') 

    news_rss_url = "http://finance.yahoo.com/rss/headline?s=%s" % stock.stock_name 
    info = feedparser.parse(news_rss_url) 
    for entry in info.entries: 
        try:         
            news = News( 
                stock = stock, 
                #news_title = entry.headline, 
                news_content = entry.description, 
                link = entry.link, 
                date = entry.modified, 
                ) 
          
            news.save()
            print news.link  
        except  News.DoesNotExist :
            raise Http404
            pass 
        
  
def save_continuously(): 
    while True: 
        save_all() 
        time.sleep(5)  